﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TARS.User;

namespace TARS.AdminCP
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            Label3.Visible = true;
            String password = Encryption.GetMd5Hash(txtPass.Text);
            using (var db = new TARSDelivery_EprojectEntities())
            {
                var getUser = db.t_User.Where(x => x.Username == txtUser.Text && x.Password == password);
                if (getUser.Count() == 0)
                    Label3.Text = "Wrong Login Infomation";
                else
                {
                    foreach (var get in getUser)
                    {
                        Session["UserID"] = get.ID;
                        Session["UserType"] = get.UserType;
                        Response.Redirect("DeliveryManager.aspx");
                    }
                }
            }
        }
    }
}